﻿@model List<HouseCrawler.Web.HouseInfo>
@using HouseCrawler.Web;

<div class="am-modal-dialog">
    @if (Model.Count == 0)
    {
        <div class="am-modal-hd">
            <a href="/Account">注册/登录</a>后可以直接在房源图标上点击"收藏图标"收藏房源.
            <br/>然后在个人中心可查看自己收藏的房源信息
            <br>(暂时只支持地图查看,即将支持房源列表.)
            <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
        </div>
    }
    else
    {
        <div class="am-modal-hd">
            房源收藏列表
            <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
        </div>
        <div class="am-modal-bd">
          <table class="am-table-centered am-table am-table-striped am-table-hover table-main" style="table-layout: fixed;">
            <thead>
                <tr>
                    <th>城市</th>
                    <th>标题</th>
                    <th>坐标</th>
                    <th>价格</th>
                    <th>发布时间</th>
                    <th>来源</th>
                    <th>操作</th>
                </tr>
            </thead>
             <tbody>
                @foreach (var house in Model)
                {
                     <tr>
                        <td>@house.LocationCityName</td>
                        <td class="ellipsis"><a href="@house.HouseOnlineURL" target="_blank">@house.HouseTitle</a></td>
                        <td class="ellipsis">@house.HouseLocation</td>
                        <td>@house.DisPlayPrice</td>
                        <td>@house.PubTime.ToString("yy-MM-dd HH:mm")</td>
                        <td>@house.DisplaySource</td>
                        <td>
                            <div class="am-text-success">
                                 <a name="removeHouse" data-id='@house.Id' href="javascript: void(0)" ><span class="am-icon-remove">移除</span></a>
                            </div>
                        </td>
                     </tr>
                }
             </tbody>
          </table>
        </div>
    }
</div>

        <script type="text/javascript">
            $(function () {
                $('body').on('click', "[name='removeHouse']", function () {
                    var $this = $(this);
                    var id = $this.attr("data-id");
                    $.ajax({
                        type: "post",
                        url: './Home/RemoveUserCollection',
                        data: { id: id },
                        success: function (result) {
                            if (result.success) {
                                alert(result.message);
                                //隐藏被删除的行
                                $this.parent().parent().parent().hide()
                            } else {
                                alert(result.error);
                            }
                        }
                    });
                });
            })
        </script>

